<?
define('BASEPATH', true);
include('../inc/config.php');

if($is_online){
	if($_GET['step'] == "skip" && $_GET['url'] != '' && is_numeric($_GET['url'])){
		$url = $db->EscapeString($_GET['url']);
	
		$db->Query("INSERT INTO `plused` (user_id, site_id) VALUES('".$data['id']."', '".$url."')");
		echo '<table cellpadding="2" cellspacing="0" width="500" align="center" class="mainfocus"><tr><td align="center"><font size="3"><b>Success!</b></font></td></tr><tr><td><center><b>You skipped this page!</center></td></tr></table>';
	}

	if(isset($_GET['data'])){
		$id = $db->EscapeString($_GET['data']);
		$site = $db->FetchArray($db->Query("SELECT id,cpc FROM `sites` WHERE `id`='".$id."'"));
		$check = $db->GetNumRows($db->Query("SELECT id FROM `plused` WHERE `user_id`='".$data['id']."' AND `site_id`='".$id."'"));
		if($id != "" && $check == 0){
			$db->Query("UPDATE `users` SET `coins`=`coins`+'".$site['cpc']."' WHERE `id`='".$data['id']."'");
			$db->Query("UPDATE `sites` SET `visits`=`visits`+'1', `points`=`points`-'".$site['cpc']."' WHERE `id`='".$site['id']."'");
			$db->Query("INSERT INTO `plused` (user_id, site_id) VALUES('".$data['id']."','".$site['id']."')");
		}
	}
}
?>